package com.cloudnote.web.util;

import java.util.List;
import java.util.ArrayList;

import com.alibaba.fastjson.JSON;

public class FastJsonTool {

	public static String createJsonString(Object obj) {
		String str = JSON.toJSONString(obj);
		return str;
	}
	
	public static <T> T getObject(String jsonString,Class<T> cls){
		T t = null;
		try{
			t = JSON.parseObject(jsonString,cls);
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return t;
	}
	
	public static <T> List<T> getObjectList(String jsonString,Class<T> cls){
		List<T> list = new ArrayList<T>();
		try{
			list = JSON.parseArray(jsonString,cls);
		}catch(Exception e){
			e.printStackTrace();
		}
		
		return list;
	}
}
